﻿//****************** AJAX ************************//
//-------------------------GET-------------------//
function funcAJAX_GET(idKetQua, strURL) {
    //create object
    var xmlHttp;
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
    else {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    // response
    xmlHttp.onreadystatechange = function () {
        document.getElementById(idKetQua).innerHTML = "<div align='center'><img src='../img/loading.gif' title='Close this notification' alt='close' /></div>";
        //alert(idKetQua);
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {

            document.getElementById(idKetQua).innerHTML = xmlHttp.responseText;
        }
    }

    // request	    
    xmlHttp.open("GET", strURL, true);
    xmlHttp.send(null);
}
//-------------------------POST -------------------//
function funcAJAX_POST(idKetQua, strURL, params) {
    //create object
    var xmlHttp;
    if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
    else {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    // response
    xmlHttp.onreadystatechange = function () {       
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {            
            document.getElementById(idKetQua).innerHTML = xmlHttp.responseText;
        }
    }
    alert(idKetQua + "," + strURL + "," + params);
    // request	
    xmlhttp.open("POST", strURL, true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.Length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.send(params);    
}